﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
using DAL.Entity;
using DAL.Persistencia;

namespace NewTierra.Pages
{
    public partial class Index : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Response.AddHeader("Last-Modified", DateTime.Now.ToString());
                Response.AddHeader("Cache-Control", "no-store, no-cache, must-revalidate, max-age=0, post-check=0, pre-check=0");
                Response.AddHeader("Pragma", "no-cache");

                CalendarioIndex.SelectedDate = DateTime.Now;

                PegaUsuario();
            }
        }

        protected void PegaUsuario()
        {
            Usuario u = Application["usuario"] as Usuario;
            lblBemVindo.Text = u.US_nome;
            lblPerfil.Text = u.Usuario_Perfil.Perfil_tipo;
        }

        protected void Sair(object sender, EventArgs e)
        {
            Application.Remove("usuario");
            Application.RemoveAll();

            FormsAuthentication.SignOut();

            Response.Redirect("/Pages/Login.aspx");
        }

        protected void ParaSupplier(object sender, EventArgs e)
        {
            Response.Redirect("Supplier/SupplierConsulta.aspx");
        }

        protected void ParaServicos(object sender, EventArgs e)
        {
            Response.Redirect("Servicos/ServicosConsulta.aspx");
        }

        protected void ParaCliente(object sender, EventArgs e)
        {
            Response.Redirect("Cliente/ClienteConsulta.aspx");
        }

        protected void ParaUserManager(object sender, EventArgs e)
        {
            Response.Redirect("Usuarios/UsuarioConsulta.aspx");
        }

        protected void ParaCashFlow(object sender, EventArgs e)
        {
            Response.Redirect("Finanças/cash_flow.mht");
        }

    }
}